package com.qingke.oms.pojo;

import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name="goods")
public class Goods {
	@Id
	@Column(name="id")
	private int id;
	
	@Column(name="code")
	private String code;
	
	@Column(name="name")
	private String name;
	
	@ManyToOne
	@JoinColumn(name="goods_type_id")
	private GoodsType goodsType;
	
	@ManyToOne
	@JoinColumn(name="manufacturer_id")
	private Manufacturer manufacturer;
	
	@Column(name="description")
	private String description;
	
	@Column(name="be_deleted")
	private boolean beDeleted;
	
	@OneToMany(mappedBy="goods",fetch=FetchType.LAZY)
	private Set<ShelfRecord> shelfRecords;
	
	@OneToMany(mappedBy="goods",fetch=FetchType.LAZY)
	private Set<ShipmentRecord> shipmentRecords;
	
	@OneToMany(mappedBy="goods",fetch=FetchType.LAZY)
	private Set<OrderItem> orderItems;
	
	@OneToMany(mappedBy="goods",fetch=FetchType.LAZY)
	private Set<ShoppingCartItem> shoppingCartItems;
	
	@OneToMany(mappedBy="goods",fetch=FetchType.LAZY)
	private Set<GoodsStatistic> goodsStatistics;
	
	
	public int getId() {
		return id;
	}


	public void setId(int id) {
		this.id = id;
	}


	public String getCode() {
		return code;
	}


	public void setCode(String code) {
		this.code = code;
	}


	public String getName() {
		return name;
	}


	public void setName(String name) {
		this.name = name;
	}


	public GoodsType getGoodsType() {
		return goodsType;
	}


	public void setGoodsType(GoodsType goodsType) {
		this.goodsType = goodsType;
	}


	public Manufacturer getManufacturer() {
		return manufacturer;
	}


	public void setManufacturer(Manufacturer manufacturer) {
		this.manufacturer = manufacturer;
	}


	public String getDescription() {
		return description;
	}


	public void setDescription(String description) {
		this.description = description;
	}


	public boolean isBeDeleted() {
		return beDeleted;
	}


	public void setBeDeleted(boolean beDeleted) {
		this.beDeleted = beDeleted;
	}


	public Set<ShelfRecord> getShelfRecords() {
		return shelfRecords;
	}


	public void setShelfRecords(Set<ShelfRecord> shelfRecords) {
		this.shelfRecords = shelfRecords;
	}


	public Set<ShipmentRecord> getShipmentRecords() {
		return shipmentRecords;
	}


	public void setShipmentRecords(Set<ShipmentRecord> shipmentRecords) {
		this.shipmentRecords = shipmentRecords;
	}


	public Set<OrderItem> getOrderItems() {
		return orderItems;
	}


	public void setOrderItems(Set<OrderItem> orderItems) {
		this.orderItems = orderItems;
	}


	public Set<ShoppingCartItem> getShoppingCartItems() {
		return shoppingCartItems;
	}


	public void setShoppingCartItems(Set<ShoppingCartItem> shoppingCartItems) {
		this.shoppingCartItems = shoppingCartItems;
	}


	public Set<GoodsStatistic> getGoodsStatistics() {
		return goodsStatistics;
	}


	public void setGoodsStatistics(Set<GoodsStatistic> goodsStatistics) {
		this.goodsStatistics = goodsStatistics;
	}


	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + id;
		return result;
	}


	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Goods other = (Goods) obj;
		if (id != other.id)
			return false;
		return true;
	}


	@Override
	public String toString() {
		String descriptionStr=(description==null||description.trim().equals(""))?"":(", [description]:" + description);
		return "Goods [id]:" + id + ", [code]:" + code + ", [name]:" + name + ", [goodsType]:" + goodsType.getName() + ", [manufacturer]:"+ manufacturer.getName() + descriptionStr ;
	}
	
}
